<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;
    String url = "jdbc:mysql://localhost:3306/rbpl";
    String user = "root";
    String password = "";
%>

<header>
        <meta charset="utf-8" />

        <title>COSTUME-IZER</title>
        <h1>COSTUME-IZER</h1>

        <!-- Our CSS stylesheet file -->
        <link rel="stylesheet" href="portfolio/assets/css/styles.css" />
        
    </header>
<%@page import="model.KostumBean" %>
<% KostumBean bean;
    bean = new KostumBean();
    //get request from servlet if data is invalid
    if (request.getAttribute("error") != null) {
        out.println("error");
        bean = (KostumBean) request.getAttribute("error");
    }
    if (request.getAttribute("updatekostum") != null) {
        bean = (KostumBean) request.getAttribute("updatekostum");
    }
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    
    <body>
        <center>
        <table align="center" width="1250" cellpadding="10" height="88" cellspacing="0" border="1">
            <tr>
                <hr width="1250"></hr>
                <td width="185" align="center" ><a href="entrikostum.jsp">Entri Kostum</a></td>
                <td width="194" align="center" ><a href="">Cari Kostum</a></td>
                <td width="646" align="right" >Selamat datang, <font style="font-style:italic" color="#3300CC"><a href="lihatdata.jsp">
                            <%try {
                                    HttpSession ses = request.getSession(true);
                                    String Username = ses.getValue("ses_Username").toString();
                                    out.println(Username);
                                } catch (Exception e) {
                                    out.println("ANDA BELUM LOGIN");
                     }%>
                        </a></font></td>  
                <td width="135" align="center" "><a href="login.jsp">Logout</a></td>
            </tr>
            <td height="144" colspan="4" ALIGN="left" >

                <form action=KostumServlet method="post">
                    <table width="1301"> 
                        <center>
                        <tr><td colspan="2"><p align="center"><strong>ENTRI DATA KOSTUM</strong></p></td>
                        </tr>
                        <td width="239">ID Kostum</td>
                        <td width="1050"><INPUT TYPE=TEXT NAME=ID_Kostum size=20 value="<%=bean.getID_Kostum()%>" <%=request.getAttribute("updatekostum") != null ? "readonly" : ""%>> <font color="red"><%=bean.getID_KostumError()%> &nbsp;</font></td>

                        </tr>
                        <tr>
                            <TD>Nama Kostum</TD>
                            <TD><INPUT TYPE=TEXT NAME=NamaKostum size=40 value="<%=bean.getNamaKostum()%>"> <font color="red"><%=bean.getNamaKostumError()%> &nbsp;</font></TD>
                            </tr>
                        <tr>
                            <TD>Harga</TD>
                            <TD><INPUT TYPE=TEXT NAME=Harga size=40 value="<%=bean.getHarga()%>"> <font color="red"><%=bean.getHargaError()%> &nbsp;</font></TD>

                        </tr>
                        <tr>
                            <TD>Kategori</TD>
                            <TD><select name=Kategori>
                                    <%
                                        try {
                                            Class.forName("com.mysql.jdbc.Driver");
                                            con = DriverManager.getConnection(url, user, password);
                                            st = con.createStatement();
                                            rs = st.executeQuery("select * from KategoriKostum");
                                            while (rs.next()) {
                                                out.println("<option> " + rs.getString(2) + " </option>");
                                            }
                                        } catch (Exception e) {
                                        }
                                    %>
                                </select>
                        </tr>
                        <tr>
                            <td>Gambar</td>
                            <td><input type=file name=Gambar value="<%=bean.getGambar()%>"></td>
                        </tr>
                        <tr>
                            <td></td>
                            <TD><input name="Simpan" type=submit value=Simpan></TD>
                        </tr>
                        </center>
                    </table>
                </form>

            </td>
        </table>
        </center>
    </body>
</html>